package com.ydd.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ydd.R;
import com.ydd.model.mina.MinaMessage;
import com.ydd.util.glide.GlideManager;

import java.util.List;

/**
 * Created by tao on 17-3-24.
 */

public class SystemMsgAdapter extends BaseQuickAdapter<MinaMessage> {
    private Context mContext;

    public SystemMsgAdapter(Context context, List<MinaMessage> data) {
        super(R.layout.item_message_card_layout, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, MinaMessage message) {

        holder.setText(R.id.day_view, message.getDayTime());
        holder.setText(R.id.site_view, message.getSite());
        holder.setText(R.id.title_view, message.getTitle());
        holder.setText(R.id.info_view, message.getInfo());
        ImageView imageView = holder.getView(R.id.image_view);
        GlideManager.loadImageView(mContext, message.getPhotoUrl(),
                (ImageView) holder.getView(R.id.item_logo_view));
        if (TextUtils.isEmpty(message.getImageUrl())) {
            imageView.setVisibility(View.GONE);
        } else {
            imageView.setVisibility(View.VISIBLE);
            GlideManager.loadImageView(mContext, message.getImageUrl(), imageView);
        }
        if (message.getType() != 3) {
            holder.setText(R.id.xiangqing_viw, mContext.getString(R.string.chart_with_me));
        } else {
            holder.setText(R.id.xiangqing_viw, mContext.getString(R.string.scan_detail));
        }
    }
}
